package com.zhangchenzhou.room.database;

import android.arch.persistence.room.TypeConverter;

import java.util.Date;

/**
 * Created by 63453 on 2018/3/24.
 */
//TypeConverters 注解放到 database中即可  @TypeConverters注解将转换器添加到AppDatabase上。@TypeConverters({Converter.class})
public class Converters {
    @TypeConverter
    public static Date fromTimestamp(Long value) {
        return value == null ? null : new Date(value);
    }

    @TypeConverter
    public static Long dateToTimestamp(Date date) {
        return date == null ? null : date.getTime();
    }
}
